﻿@using WaterRevenueMS.WebUI.Extension.MvcHelper
@using WaterRevenueMS.Domain.ViewModels.ReadMeterMS.TaskTemplet
@model TaskTempletModel


@using (Html.BeginForm("Create", "TaskTemplet", FormMethod.Post, new { @class = "form-horizontal", @id = "modal-content" }))
{
<div class="control-group">
    <label class="control-label-form">
        <label class="red">*</label>模版名称 :
    </label>
    <div class="controls">
        @Html.TextBoxFor(t => t.Ren_WMC, new { @class = "form-control" })
        @Html.ValidationMessageFor(m => m.Ren_WMC)
    </div>
</div>


<div class="control-group">
    <label class="control-label-form">
      抄表年度:
    </label>
    <div class="controls">
        @Html.TextBoxFor(t => t.Chao_BND, new { @class = "form-control" })
        @Html.ValidationMessageFor(m => m.Chao_BND)
    </div>
</div>


<div class="control-group">
    <label class="control-label-form">
       抄表月度:
    </label>
    <div class="controls">
        @Html.TextBoxFor(t => t.Chao_BYD, new { @class = "form-control" })
        @Html.ValidationMessageFor(m => m.Chao_BYD)
    </div>
</div>

<div class="control-group">
    <label class="control-label-form">
       <label class="red">*</label>区域名称:
    </label>
    <div class="controls">
        @Html.DropDownListFor(t => t.Qu_YSZ_No, Model.Areas, new { @class = "form-control" })
        @Html.ValidationMessageFor(m => m.Qu_YSZ_No)
    </div>
</div>

<div class="control-group">
    <label class="control-label-form">
       表册名称:
    </label>
    <div class="controls">
        @Html.DropDownListFor(t => t.Biao_CSZ_No, Model.MeterBooks, new { @class = "form-control" })
        @Html.ValidationMessageFor(m => m.Biao_CSZ_No)
    </div>
</div>

<div class="control-group">
    <label class="control-label-form">
        抄表员名称:
    </label>
    <div class="controls">
        @Html.DropDownListFor(t => t.Chao_BY_No, Model.MeterReaders, new { @class = "form-control" })
        @Html.ValidationMessageFor(m => m.Chao_BY_No)
    </div>
</div>
}
@Html.ScriptBlock(
    @<script type="text/javascript">
         var areaJson;
         var temp_html;
         var oArea = $("#Qu_YSZ_No");
         var oBldg = $("#Biao_CSZ_No");
         var area = function () {
             $.each(areaJson, function (i, area) {
                 temp_html += "<option value='" + area.AreaID + "'>" + area.AreaName + "</option>";
             });
             $("#Qu_YSZ_No").html(temp_html);
             bldg();
         };
         var bldg = function () {
             temp_html = "";
             var n = oArea.get(0).selectedIndex;
             $.each(areaJson[n].Bldgs, function (i, bldg) {
                 temp_html += "<option value='" + bldg.BldgID + "'>" + bldg.BldgName + "</option>";
             });
             oBldg.html(temp_html);
         };
         oArea.change(function () {
             bldg();
         });
         $.ajax({
             url: "/TaskTemplet/GetAreaJson",
             type: "get",
             cache: false,
             dataType: 'json',
             success: function (data) {
                 areaJson = data;
                 area();
             },
             error: function () {

             }
         });
    </script>
)